package com.sanerzone.smscenter.modules.sms.service;

import com.sanerzone.jeebase.common.persistence.Page;
import com.sanerzone.jeebase.common.service.CrudService;
import com.sanerzone.smscenter.biz.config.PhoneConfigInterfaceImpl;
import com.sanerzone.smscenter.biz.iface.PhoneConfigInterface;
import com.sanerzone.smscenter.common.utils.SysBlacklistUtils;
import com.sanerzone.smscenter.modules.sms.dao.SmsPhoneBlacklistChangeDao;
import com.sanerzone.smscenter.modules.sms.entity.SmsPhoneBlacklistChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2018/4/11.
 */
@Service
@Transactional(readOnly = true)
public class SmsPhoneBlacklistChangeService extends CrudService<SmsPhoneBlacklistChangeDao,SmsPhoneBlacklistChange>{

    public SmsPhoneBlacklistChange get(String id) {
        return super.get(id);
    }

    //	@Autowired
    private PhoneConfigInterface phoneConfigInterfaceImpl = new PhoneConfigInterfaceImpl();

    @Autowired
    private SmsPhoneBlacklistChangeDao smsPhoneBlacklistChangeDao;

    private SmsPhoneBlacklistService smsPhoneBlacklistService = new SmsPhoneBlacklistService();

    public List<SmsPhoneBlacklistChange> findList(SmsPhoneBlacklistChange smsPhoneBlacklistChange) {
        return super.findList(smsPhoneBlacklistChange);
    }

    public Page<SmsPhoneBlacklistChange> findPage(Page<SmsPhoneBlacklistChange> page, SmsPhoneBlacklistChange smsPhoneBlacklistChange) {
        return super.findPage(page, smsPhoneBlacklistChange);
    }

    @Transactional(readOnly = false)
    public void update(SmsPhoneBlacklistChange smsPhoneBlacklistChange) {
        dao.update(smsPhoneBlacklistChange);
        phoneConfigInterfaceImpl.configBlacklistChange(1, smsPhoneBlacklistChange.getId(), null);//广播通知 修改黑名单记录
    }

    @Transactional(readOnly = false)
    public void delete(SmsPhoneBlacklistChange smsPhoneBlacklistChange) {
       dao.delete(smsPhoneBlacklistChange);
        phoneConfigInterfaceImpl.configBlacklistChange(2, smsPhoneBlacklistChange.getId(), null);//广播通知 删除黑名单记录

    }
}
